﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
namespace Ecreate.Data
{
    public sealed class QueryParameter
    {
        private ParameterDirection m_Direction;
        private string m_ParameterName;
        private object m_Value;

        public QueryParameter(string ParameterName, object Value)
        {
            this.init(ParameterName, Value);
            this.m_Direction = ParameterDirection.Input;
        }

        public QueryParameter(string ParameterName, object Value, ParameterDirection direction)
        {
            this.init(ParameterName, Value);
            this.m_Direction = direction;
        }


        private void init(string ParameterName, object Value)
        {
            if (PersistenceProperty.DatabaseType == DataBaseType.MSSQLServer)
            {
                this.m_ParameterName = ParameterName.Replace(":", "@");
                this.m_Value = Value;
            }
            else
            {
                this.m_ParameterName = ParameterName.Replace("@", ":");
                this.m_Value = Value;
            }
        }

        public ParameterDirection Direction
        {
            get
            {
                return this.m_Direction;
            }
            set
            {
                this.m_Direction = value;
            }
        }



        public string ParameterName
        {
            get
            {
                return this.m_ParameterName;
            }
            set
            {
                this.m_ParameterName = value;
            }
        }

        public object Value
        {
            get
            {
                return this.m_Value;
            }
            set
            {
                this.m_Value = value;
            }
        }
    }
}
